package common.fengkai.filepost.utils;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import common.fengkai.filepost.VO.ResVoTO;
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.entity.StringEntity;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.util.EntityUtils;

import java.io.IOException;
import java.net.HttpURLConnection;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.LinkedHashMap;
import java.util.Map;

public class CheckTestPdf {
       public static void main(String[] args) throws Exception {
           String url = "http://10.29.31.58:8002/eseal/app/services/checkPdf";
           Map<String, Object> map = new LinkedHashMap<String,Object>();

           String s = Base64util.encodeBase64File("C:\\Users\\carry\\Desktop\\项目资料\\人管合同8页signed.pdf");
           map.put("signPdf",s);
           String s1 = JSON.toJSONString(map);
           System.out.println(s1);
           HttpClient httpClient = HttpClients.createDefault();
           HttpPost httpRequest = new HttpPost(url);
           httpRequest.setHeader("Content-Type", "application/json");
           httpRequest.setEntity(new StringEntity(s1,"UTF-8"));
           HttpResponse response = httpClient.execute(httpRequest);

           HttpEntity entity = response.getEntity();//
           if (response.getStatusLine().getStatusCode() == HttpURLConnection.HTTP_OK) {
               String result = EntityUtils.toString(entity);
               JSONObject jsonObject = JSONObject.parseObject(result);
               System.out.println(result);
           }

       }




}
